<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>await</title>
</head>
<body>
	<script>
		async function main() {
			let p = new Promise((resolve,reject)=>{
				//resolve('ok')
				reject('err')
			})
			// 1. 右侧为 promise 的情况
			let res = await p
			console.log(res);// ok
			// 2. 右侧为非 promise 的情况
			let res2 = await '20'
			console.log(res2);// 20
			// 3. 如果 promise 是失败的状态
			try {
				let res3 = await p
			} catch (error) {
				console.log(error);// err
			}
		}
		main()
	</script>
</body>
</html>